//perform the big merge
//use "$temp/census_long_pik_master_clean", clear
//drop if pik==""
//save "$temp/census_long_pik_master_clean_nomiss", replace

use "$temp/acs_sample_pik", clear //load ACS sample

preserve
keep if pik == ""
tempfile missing
save `missing'
restore
drop if pik == ""

//some xyz in pik, but no xyz in pik-year, so we're good with an m:1 merge

//merge on Census information --long form
merge m:1 pik using "$temp/census_long_pik_master_clean", keep(1 3) 
ren _merge merge_long
count if merge_long==3 & dby>=1990

//isolate long-form merges
preserve
keep if merge_long == 3
tempfile long
save `long'
restore
drop if merge_long == 3
drop *_2000

//merge on Census information --short form
merge m:1 pik using "$temp/census_short_pik_master_clean", keep(1 3)
ren _merge merge_short
append using `long' //add long-form merges back information
append using `missing' //add people without PIKS

count if (dby>=1990 & dby<=1994) & merge_long==3 //sample size
save "$temp/acs_census_merged_sample", replace


